package r6.pierwszy.raz;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.util.Date;

import javax.swing.JOptionPane;
import javax.swing.Timer;

public class Zegarynka implements Runnable {

	private class ZegarListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			System.out.println(DateFormat.getTimeInstance().format(new Date()));
		}

	}

	public Zegarynka(int interval) {
		this.interval = interval;
	}

	public Zegarynka() {
		this(1000);
	}

	private int interval;

	@Override
	public void run() {
		new Timer(interval, new ZegarListener()).start();
		JOptionPane.showMessageDialog(null, "Koniec");
		System.exit(0);
	}

}
